package com.sbtr.common;

import org.springframework.lang.Nullable;

/**
 * 接口常用常量定义
 *
 * @author qiujun
 * @date 2019-10-29
 */
public enum ResultCodeCanstant {

	OK(200, "ok"), SYSTEN_ERROR(9100, "system error"), PARAMETER_ERROR(9500, "parameteer error");

	private final int value;
	private final String reasonPhrase;

	ResultCodeCanstant(int value, String reasonPhrase) {
		this.value = value;
		this.reasonPhrase = reasonPhrase;
	}

	public int getValue() {
		return value;
	}

	public String getReasonPhrase() {
		return reasonPhrase;
	}

	public static ResultCodeCanstant valueOf(int statusCode) {
		ResultCodeCanstant status = resolve(statusCode);
		if (status == null) {
			throw new IllegalArgumentException("No matching constant for [" + statusCode + "]");
		} else {
			return status;
		}
	}

	@Nullable
	public static ResultCodeCanstant resolve(int statusCode) {
		ResultCodeCanstant[] var1 = values();
		int var2 = var1.length;

		for (int var3 = 0; var3 < var2; ++var3) {
			ResultCodeCanstant status = var1[var3];
			if (status.value == statusCode) {
				return status;
			}
		}
		return null;
	}
}
